import { View, Label, Checkbox } from "@tarojs/components"
import $style from './index.module.scss'

export default (props:{children?:any;checked?:boolean;indeterminate?:boolean;value:any;className?:string;}) => {
    let labelClassName = $style.label
    if(props.checked) {
        labelClassName += ' ' + $style.checked
    }
    
    if(props.indeterminate) {
        labelClassName += ' ' + $style.indeterminate
    }
    if(props.className) {
        labelClassName += ' ' + props.className
    }

    let _props = {...props}
    if(_props.hasOwnProperty('className')) {
        delete _props.className
    }
    if(_props.hasOwnProperty('children')) {
        delete _props.children
    }

    function f(params) {
        console.log(params)
    }

    return <Label className={$style.container}>
        <View className={labelClassName}>
            <View className={$style.check + ' at-icon at-icon-check'}></View>
        </View>
        <View className={$style.title}>{props.children}</View>
        <Checkbox className={$style.Checkbox} {..._props}></Checkbox>
    </Label>
}